class Initial < ActiveRecord::Migration
  def self.up

    puts "Creating DB Schema..."
    ActiveRecord::Schema.define() do

      create_table "groups", :force => true do |t|
        t.column "name", :string, :limit => 50, :null => false
        t.column "description", :string, :limit => 250
        t.column "status", :integer, :default => 0
        t.column "created_at", :datetime, :null => false
        t.column "updated_at", :datetime, :null => false
      end

      create_table "users", :force => true do |t|
        t.column "surname", :string, :limit => 10, :null => false
        t.column "firstname", :string, :limit => 20, :null => false
        t.column "email", :string, :limit => 50, :null => false
        t.column "password", :string, :limit => 32, :null => false
        t.column "gender", :string, :limit => 1
        t.column "city", :string, :limit => 50
        t.column "address", :string, :limit => 200
        t.column "zipcode", :string, :limit => 10
        t.column "phone", :string, :limit => 20
        t.column "balance", :float, :default => 0
        t.column "group_id", :integer, :null => false, :default => 1
        t.column "status", :integer, :default => 0
        t.column "activation_code", :string, :limit => 32
        t.column "activated_at", :datetime
        t.column "login_at", :datetime
        t.column "login_from", :string, :limit => 15
        t.column "created_at", :datetime, :null => false
        t.column "updated_at", :datetime, :null => false
      end

      add_index "users", ["email"], :name => "users_1ix"

      create_table "orders", :force => true do |t|
        t.column "order_code", :string, :limit => 12, :null => false
        t.column "amount", :float, :default => 0
        t.column "consignee", :string, :limit => 30, :null => false
        t.column "address", :string, :limit => 200, :null => false
        t.column "zipcode", :string, :limit => 10
        t.column "phone", :string, :limit => 20, :null => false
        t.column "shipment_id", :integer, :null => false
        t.column "payment_id", :integer, :null => false
        t.column "user_id", :integer, :null => false
        t.column "status", :integer, :default => 0
        t.column "has_paid", :float, :default => 0
        t.column "present", :text
        t.column "need_receipt", :string, :limit => 1
        t.column "created_at", :datetime, :null => false
        t.column "updated_at", :datetime, :null => false
      end

      add_index "orders", ["order_code"], :name => "orders_1ix"

      create_table "order_items", :force => true do |t|
        t.column "order_id", :integer, :null => false
        t.column "product_id", :integer, :null => false
        t.column "amount", :float, :default => 0
        t.column "discount", :float, :default => 0
        t.column "created_at", :datetime, :null => false
        t.column "updated_at", :datetime, :null => false
      end

    end
    puts "Creation Done!"
      
  end

  def self.down
  end
end
